package com.gw.booking.service;



import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;

@Service("scheduleService")
public class ScheduleService {
	@Autowired
	private SessionFactory sessionFactory;
	@Autowired
	private LoginTokenService loginTokenService;
	@Autowired
	private AttachmentService attachmentService;
	@Autowired
	private DiscountService discountService;
	@Autowired
	private OrderService orderService;

	Logger logger = LoggerFactory.getLogger(ScheduleService.class);

	/**
	 * 清除过期token
	 */
	public void txClearOverdueTokens() {
		logger.info("##############清除过期token开始");
		loginTokenService.clearOverdueTokens();
		logger.info("##############清除过期token结束");
	}

	/**
	 * 清除临时文件
	 */
	public void txClearTmpFiles() {
		logger.info("##############清除临时文件开始");
		attachmentService.clearTmpFiles();
		logger.info("##############清除临时文件结束");
	}

	/**
	 * 	清理过期优惠
	 */
	public void txUpdateDiscount() throws ParseException {
		logger.info("##############清理过期优惠开始");
		discountService.txAutoUpdate();
		logger.info("##############清理过期优惠结束");
	}

	/**
	 * 	清理过期订单
	 */
	public void txUpdateOrder() throws ParseException {
		logger.info("##############清理过期订单开始");
		orderService.txAutoUpdate();
		logger.info("##############清理过期订单结束");
	}
}
